Skip to content

upload-types: a stricter text test, text types by extension, HEIF by brand; v0.14.0 - #54

Merged
JaimeStill merged 8 commits into
mainfrom
upload-types
Dec 2, 2026
Merged

JaimeStill merged 8 commits into
mainfrom
upload-types

Conversation

@JaimeStill

Copy link
Copy Markdown
Contributor

capstone.data-intelligence.mikoshi · task 29/39 · upload-types · brief 1 of 2: docproc

Summary

  • docproc's text test is stricter. Content with no signature is text only when its first 4096
    bytes hold no control byte other than tab, LF, CR, and FF (and no DEL), and are valid UTF-8 or
    windows-1252 without its five undefined bytes. Before, any head without a NUL byte was text.
    route.At and route.MediaType share the test, and a byte order mark still comes first.
  • route.MediaType gives text its registered type by extension: .md is text/markdown, .csv
    text/csv, .json application/json, .yaml application/yaml, and so on. Text with any
    other extension is text/plain; content that isn't text is application/octet-stream.
  • HEIF is typed by its major brand: image/heic, image/heic-sequence, image/heif, or
    image/heif-sequence. Routing is unchanged.
  • docproc's sub-modules require the base at v0.13.0; two tools take pin-project-lite 0.2.19.
  • Mikoshi's slices 4–6 (the upgrades, typing at completion, the browser tier's typeless upload)
    build on the v0.14.0 tag after this SHIP, and come back as brief 2.

Core changes

  1. The shared text test (route.At's fallback, mbox and message claims, and the stored
    audio/video check). Why: a log of terminal escapes or a binary with no NUL in its head was
    routed as text and decoded into mojibake.
  2. The extension table for text in route.MediaType. Why: sl-artifact-viewer renders
    text/markdown as Markdown and application/json as JSON. The root's dataset loader already
    types with docproc, so its .md and .json items are stored as text/plain today.
    func MediaType(r io.ReaderAt, size int64, head []byte, name, mimeType string) (string, error)
  3. HEIF by brand, through a majorBrand helper that Identify shares. Why: mif1 and
    msf1 files were called image/heic, which the registry reserves for HEVC-coded images.

Verify

mise run check (docproc): ✓ check: ok · mise run currency: ✓ only held items (MimeKit, MsgKit,
typed-path)

  1. In a scratch module that requires the upload-types checkout, call route.MediaType on a
    UTF-8 file named notes.md: text/markdown. Name it notes.txt: text/plain. Change one byte
    to 0x01 and name it notes.md: application/octet-stream.
  2. A build.log holding terminal escapes and no NUL: route.At gives unrouted, reason "no
    routed signature, not text". A windows-1252 file with smart quotes (0x93, 0x94): text. Any of
    0x81, 0x8D, 0x8F, 0x90, or 0x9D: unrouted.
  3. A UTF-16LE file with its byte order mark: text, by its mark.
  4. HEIF heads by major brand: heic → image/heic, hevc → image/heic-sequence, mif1 and
    miaf → image/heif, msf1 → image/heif-sequence. Each still routes vision-converted.
  5. CHANGELOG.md's [v0.14.0] - 2026-12-02 marks the text test Breaking and lists the new types;
    README's go get names v0.14.0.

Decided without you

  1. A UTF-8 rune cut at the head's end counts as valid only when the content runs past the head.
    A partial rune where the file ends is invalid UTF-8, though it can still pass as windows-1252.
  2. Content of no signature stored as audio or video now routes Audio or Video when its head fails
    the new test (before: when it held a NUL). The release notes say so.
  3. A valid-UTF-8 head holding a C1 code point (such as U+0085) is text, as the brief reads. My
    slice brief had asked for a rule rejecting it; the spec review caught it and it was removed.
  4. The [v0.14.0] changelog heading is cut in this pull request, as docproc's v0.13.0 was.
  5. The HEIF and extension-table entries sit under Changed, not marked Breaking; only the text test
    is.

Redirects and escalations

none

Merge danger: one-way door: the tag docproc v0.14.0, with a stricter text test that changes
how route.At routes content holding control bytes · blast radius: docproc's consumers on upgrade
(Mikoshi in this task; Bunrei and the root's loader at their next currency) · docproc: merge
waits on checks, tag waits on ci

Needs you: accept to publish, merge, and tag docproc v0.14.0

…pin-project-lite 0.2.19

- storage, postgres, and cmd/docproc require the base module at v0.13.0,
  through `mise run upgrade`. Their Unreleased bullet, which recorded the
  untagged move to v0.12.0, now reads v0.13.0, from v0.11.0, the version
  each module's last release required.
- tools/mail and tools/onenote lock pin-project-lite 0.2.19, recorded
  under Unreleased in each tool's CHANGELOG.
- Holds stay: tools/mail MimeKit 5.0.0 and MsgKit 3.1.0, tools/onenote
  typed-path 0.13.0. Nothing tagged.
… UTF-8 or windows-1252

Content of no routed signature, or that fails a claim's own check, is text only
when its first HeadLen bytes hold no control byte (C0 but tab, LF, FF, CR; DEL)
and are valid UTF-8 with no C1 code point, or windows-1252 without its five
undefined bytes. The NUL-only test is gone from every fallback: no signature,
the OLE2 and mbox claims, and the .eml or message-typed header. route.At and
route.MediaType share it. A byte order mark still makes content text ahead of
the test.

Decisions:
- A rune cut off at the head's end is valid when the content runs past the
  head (len(head) < size), whatever the head's length, not only at HeadLen.
- A C1 code point in valid UTF-8 makes the head not text; the same bytes are
  not retried as windows-1252.
- storedMedia's stored audio or video type routes content whose head isn't
  text by the new test, since its doc ties it to the fallback's refusal.

Test changed: file_test's "escape and bell" is unrouted, not text.
…EIF by brand

- Text of no signature (At's head-text fallback) takes its type from route's
  own extension table, by Ext: .md/.markdown, .csv, .tsv, .html/.htm, .xml,
  .json, .yaml/.yml, .css, .js/.mjs, .ics, .vcf; any other is text/plain.
  BOM and shebang kinds still type text/plain via kindTypes before At runs,
  so the table applies on the fallback path alone. No mime.TypeByExtension.
- A HEIC's type comes from its ftyp major brand: image/heic, heic-sequence,
  heif, or heif-sequence. majorBrand is extracted from isISOBMFF and shared;
  HEIC leaves kindTypes since heifTypes covers every brand Identify maps to
  HEIC (heicBrands and structuralBrands). Routing is unchanged.
- CHANGELOG Unreleased ### Changed, MediaType's doc comment, route/doc.go's
  inventory, and docs/api.md's route block state the table and the brands.
…0] - 2026-12-02 per release-and-ci.md, compare links extended, README's go get names v0.14.0
…code point is text

The approved brief tests control bytes only (C0 besides tab, LF, CR, FF, and
DEL); textual also refused a valid-UTF-8 head holding U+0080-U+009F, a rule the
brief doesn't have. The rule is removed: a head such as 61 C2 85 62 0A is valid
UTF-8 with no control byte, so it is text.

utf8Whole becomes utf8Head, returning only whether the head is UTF-8, since no
caller needs the trimmed slice any more. The 'utf-8 c1 control' case in
route/test/at_test.go now expects route.Text and text/plain. The C1 mention is
dropped from the Text constant's doc, route/doc.go, docs/limits.md, and the
CHANGELOG [v0.14.0] Breaking entry.
@JaimeStill
JaimeStill merged commit 2a287f7 into main Dec 2, 2026
11 checks passed
@JaimeStill
JaimeStill deleted the upload-types branch December 2, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant